var giftMaxNum = 5;
var itemReward = new Array(Array(2001516, 100, 1), Array(2002036, 100, 1), Array(5040005, 100, 1), Array(2100900, 1, 1), Array(2002036, 100, 2), Array(2431887, 30, 2), Array(2001505, 100, 2), Array(2001556, 100, 2), Array(2001537, 50, 2), Array(2001538, 50, 2), Array(2001539, 50, 2), Array(2100900, 2, 2), Array(-1, 1000, 2), Array(2002036, 100, 3), Array(2002036, 100, 3), Array(2431887, 30, 3), Array(2001505, 300, 3), Array(2001556, 100, 3), Array(2100900, 3, 3), Array(-1, 2000, 3), Array(2002036, 100, 4), Array(2431887, 50, 4), Array(2001505, 300, 4), Array(2001505, 200, 4), Array(2001556, 200, 4), Array(2100900, 4, 4), Array(-1, 3000, 4), Array(2002036, 100, 5), Array(2431887, 100, 5), Array(2001505, 300, 5), Array(2001505, 300, 5), Array(2001556, 200, 5), Array(2100900, 5, 5), Array(-1, 4000, 5));

function start() {
    var c = 1;
    var d = new Array();
    var a = im.getPlayer().getLevel();
    var e = 0;
    var f = "";
    for (var b = 1; b <= 5; b++) {
        if (im.getBossLog("新手礼包" + b) != -1) {
            c = b;
            break
        }
    }
    switch (c) {
        case 1:
            e = 1;
            break;
        case 2:
            e = 30;
            break;
        case 3:
            e = 60;
            break;
        case 4:
            e = 100;
            break;
        case 5:
            e = 150;
        default:
            break
    }
    if (c > 1 && im.getGamePoints() < (c * 10)) {
        im.playerMessage(1, "在线时间不足" + (c * 10) + "分钟，无法打开礼包\r\n还需坚持 " + (c * 10 - im.getPlayer().getTodayOnlineTime()) + "分钟");
        im.dispose();
        return
    }
    if (a < e) {
        f = "【特殊超值礼包礼物箱】\r\n(需" + e + "级才能打开)\r\n打开后可获得下列物品：\r\n\r\n";
        for (var b = 0; b < itemReward.length; b++) {
            if (itemReward[b][2] == c) {
                if (itemReward[b][0] == -1) {
                    f += "抵用券 " + itemReward[b][1] + " 点\r\n"
                } else {
                    f += im.getItemName(itemReward[b][0]) + " × " + itemReward[b][1] + " 个\r\n"
                }
            }
        }
        im.playerMessage(1, f);
        im.dispose();
        return
    }
    for (var b = 0; b < itemReward.length; b++) {
        if (itemReward[b][2] == c) {
            d.push(itemReward[b])
        }
    }
    if (im.getInventory(2).isFull(d.length - 1)) {
        im.playerMessage(1, "【特殊超值礼包礼物箱】\r\n(" + e + "级礼包)\r\n\r\n消耗栏空间不足，需要 " + d.length + " 格空间。");
        im.dispose();
        return
    } else {
        if (im.getInventory(3).isFull(1)) {
            im.playerMessage(1, "【特殊超值礼包礼物箱】\r\n(" + e + "级礼包)\r\n\r\n设置栏空间不足，需要 1 格空间。");
            im.dispose();
            return
        }
    }
    for (var b = 0; b < d.length; b++) {
        if (d[b][0] == -1) {
            im.getPlayer().modifyCSPoints(2, d[b][1]);
            f += "抵用券 " + d[b][1] + " 点\r\n";
            continue
        }
        im.gainItem(d[b][0], d[b][1]);
        f += im.getItemName(d[b][0]) + " × " + d[b][1] + " 个\r\n"
    }
    if (c == giftMaxNum) {
        im.gainItem(2431092, -1)
    }
    im.setBossLog("新手礼包" + c, 1, -1);
    im.playerMessage(1, "【特殊超值礼包礼物箱】\r\n(" + e + "级礼包)\r\n恭喜您已获得：\r\n\r\n" + f);
    im.dispose()
}
var status = -1;